﻿using UnityEngine;
using System.Collections;

public class LateSpeedAdjust : MonoBehaviour {

    private float lateSpeedAdjustment = 1.0f;

    public float maximumSpeed = 10.0f;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

    void LateUpdate()
    {
        if (lateSpeedAdjustment != 1.0f)
        {
            this.rigidbody.velocity *= lateSpeedAdjustment;
            lateSpeedAdjustment = 1.0f;
        }

        if (this.rigidbody.velocity.magnitude > maximumSpeed)
        {
            this.rigidbody.velocity = this.rigidbody.velocity.normalized * maximumSpeed;
        }
    }

    public void SetAdjustment(float value)
    {
        lateSpeedAdjustment = value;
    }
}
